<template>
	<view>
		
	</view>
</template>

<script setup>
import axios from 'axios';
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();


const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const code = urlParams.get('code');
console.log(code)
const getDINGcallback=()=>{
	console.log(code)
	axios.get(`http://127.0.0.1:8000/user/dingtalkCallback/?code=`+code)
	.then(res=>{
		console.log(res)
		if (res.data.token){
			// alert("登录成功")
			localStorage.setItem('token',res.data.token)
			router.push({path:'/pages/home/home'})
		}	
	})
	.catch(err=>{
		console.log(err,"登陆失败")
	})
}
// 监听路由变化，获取钉钉回调携带的 code
onMounted(() => {
  	getDINGcallback();
});
</script>

<style>

</style>
